﻿@namespace AntDesign
@inherits OverlayTrigger

@using AntDesign.Internal

@if (ChildContent != null)
{
    <div class="@ClassMapper.Class" @ref="@Ref" Id="@Id" style="display: inline-flex; @Style"
         @onclick="OnClickDiv"
         @onmouseenter="OnTriggerMouseEnter"
         @onmouseleave="OnTriggerMouseLeave"
         @oncontextmenu="OnTriggerContextmenu"
         @onfocusin="OnTriggerFocusIn"
         @onfocusout="OnTriggerFocusOut"
         @oncontextmenu:preventDefault>
        @ChildContent
    </div>
}
@if (Unbound != null)
{
    @Unbound(RefBack)
}


<CascadingValue Value="this" Name="Trigger" IsFixed="@true">
    <CascadingValue Value="@ArrowPointAtCenter" Name="ArrowPointAtCenter">
        <Overlay @ref="_overlay"
                 OnOverlayMouseEnter="OnOverlayMouseEnter"
                 OnOverlayMouseLeave="OnOverlayMouseLeave"
                 OnOverlayMouseUp="OnOverlayMouseUp">

            <div class="ant-popover-content">
                <div class="ant-popover-arrow">
                    <span class="ant-popover-arrow-content"></span>
                </div>
                <div class="ant-popover-inner" role="tooltip">
                    <div class="ant-popover-inner-content">
                        <div class="ant-popover-message">
                            <span class="ant-popover-message-icon">
                                @if (IconTemplate != null)
                                {
                                    @IconTemplate
                                }
                                else
                                {
                                    <Icon Type="@Icon" />
                                }
                            </span>
                            <div class="ant-popover-message-title">
                                @if (TitleTemplate != null)@TitleTemplate else @Title
                            </div>
                        </div>
                        <div class="ant-popover-buttons">
                            @if (CancelButtonProps != null)
                            {
                                <Button OnClick="@Cancel" Size="@CancelButtonProps.Size"
                                        Block="@CancelButtonProps.Block"
                                        Ghost="@CancelButtonProps.Ghost"
                                        Loading="@CancelButtonProps.Loading"
                                        Type="@CancelButtonProps.Type"
                                        Shape="@CancelButtonProps.Shape"
                                        Icon="@CancelButtonProps.Icon"
                                        Disabled="@CancelButtonProps.Disabled"
                                        Danger="@CancelButtonProps.IsDanger">
                                    @CancelText
                                </Button>
                            }
                            @if (OkButtonProps != null)
                            {
                                <Button OnClick="@Confirm" Size="@ButtonSize.Small" Type="@OkType"
                                        Block="@OkButtonProps.Block"
                                        Ghost="@OkButtonProps.Ghost"
                                        Loading="@OkButtonProps.Loading"
                                        Shape="@OkButtonProps.Shape"
                                        Icon="@OkButtonProps.Icon"
                                        Disabled="@OkButtonProps.Disabled"
                                        Danger="@OkButtonProps.IsDanger">
                                    @OkText
                                </Button>
                            }
                        </div>
                    </div>
                </div>
            </div>
        </Overlay>
    </CascadingValue>
</CascadingValue>